<template>
  <div>
    <div v-for="i in parms">
      <van-field :label="i.name" v-model="values[i.name]"></van-field>

    </div>
    <van-button @click="add">添加</van-button>
    <van-button @click="add1"></van-button>

  </div>
</template>

<script>
export default {
  name: "add_apply",
  data() {
    return {
      parms: [],
      wid: this.$route.query.id,
      values: {},
    }
  },
  methods: {
    getparms() {
      this.$axios.get('/day01/update?id=' + this.wid)
        .then(res => {
          if (res.data.code == 200) {
            this.parms = JSON.parse(res.data.list.parms)
          }
        })
    },
    add() {
      console.log(this.values)
      this.$axios.post('/day01/apply', {'userid': 1, 'wid': this.wid, 'params': this.values})
        .then(res => {
          if (res.data.code == 200) {
            alert('添加成功')
          }
        })
    },
    add1() {
      this.$toast.loading({
        mask:true,
        message:'加载中...',
        position:'top'
      })
    }
  },
  mounted() {
    this.getparms()
  }
}
</script>

<style scoped>

</style>
